<template>
	<view class="padding-bottom-xl">
    <view class="u-content text-lg" v-text="title"></view>
    <view class="cu-bar u-title" >
      <view class="action">
        <view class="text-sm text-gray">{{author}}</view>
      </view>
      <view class="action">
        <view class="padding-right-xs text-sm text-gray">{{formatDate}}</view>
      </view>
    </view>
    <van-divider :style="{ color: '#e7e7e7', borderColor: '#e7e7e7', padding: '0 3%' }" />
    <view class="padding-left padding-right news-content" v-html="content"></view>
    <view v-show="showSource" class="padding text-sm fr">信息来源：{{source}}</view>
	</view>
</template>

<script>
	export default {
    onLoad: function(option) {
      this.fromType = option.from
      let obj = {}
      const eventChannel = this.getOpenerEventChannel();
      // 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据
      eventChannel.on('acceptDataFromOpenerPage', function(data) {
        obj = data
      })
      if(this.fromType == 'news') {
        this.title = obj.infoTitle;
        this.author = '发布单位：'+ obj.deptName;
        this.date = obj.publishDate;
        this.content = obj.infoContent;
        this.source = obj.infoCome;
      } else if (this.fromType == 'notice') {
        this.title = obj.title;
        this.author = '发布单位：'+ obj.deptName;
        this.date = obj.createTime;
        this.content = obj.tgContent;
        this.showSource = false;
      } else if (this.fromType == 'hlwzy') {
        this.title = obj.title;
        this.author = '发布人：'+ obj.infoUser;
        this.date = obj.pushTime;
        this.content = obj.infoBody;
        this.showSource = false;
      }else if (this.fromType == 'zywj') {
        this.title = obj.title;
        this.author = '发布人：'+ obj.infoUser;
        this.date = obj.pushTime;
        this.content = obj.infoBody;
        this.showSource = false;
      }


    },

		data() {
			return {
			  fromType: 'news',
        showSource: true,
        title: '',
        author: '',
        date: '',
        content: '',
        source: ''
			}
		},

    computed: {
      formatDate() {
        let formatStr = this.date
        if(formatStr != null && formatStr != '' && formatStr.length > 10) {
          formatStr = formatStr.substr(0, 10)
        }
        return formatStr
      }
    },

    methods: {

    }
	}
</script>

<style>
	.u-content {
		margin-top: 20rpx;
    padding: 20rpx;
    text-align: center;
    font-weight: 400;
	}
	.u-title{
		margin-bottom: -30rpx;
	}
  .news-content {
    line-height: 2.3em;
    text-indent: 2em;
    font-weight: 400;
    color: #6f6868;
    word-break: break-all;
  }
  .news-content>>> img{
    width: 100%;
    display: block;
  }
</style>
